import TestApi from "../api/test.js";
import Base from "./base.js";
//辅助函数
function run(gen) {
    const it = gen();
    function next(data) {
        const { value, done } = it.next(data);
        if (done) return value;
        if (Object.prototype.toString.call(value) === "[object Promise]") {
            return value.then(data => next(data));
        } else {
            return next(value);
        }
    }
    return next();
}
export default class extends Base {
    render() {
        this.$el.html(`
            <div><h1>test</h1></div>
            <button class="btn">点击</button>
        `);
        this.$btn = $(".btn");
    }
    handle() {
        // this.$btn.on("click", function () {
        //     run(TestApi.gen).then(console.log);
        // });
        this.$btn.on("click", async function () {
            console.log(await TestApi.asyncFn());
        });
    }
}